package cn.com.lsy.product.lepao.listener;

import cn.com.lsy.product.lepao.event.AddUserMessageEvent;
import cn.com.lsy.product.lepao.model.mt.entities.AddUserMessageDto;
import cn.com.lsy.product.lepao.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class AddUserMessageListener {

    @Autowired
    IMessageService iMessageService;

    /**
     * 注册监听实现方法
     *
     * @param event test事件
     */
    @Async
    @EventListener
    public void test(AddUserMessageEvent event) {

        AddUserMessageDto addUserMessageDto = event.getAddUserMessageDto();

        iMessageService.insertUserMessage(addUserMessageDto.getMsgId(), addUserMessageDto.getPhoneList());
    }
}
